Learn R Programming

gmp (version 0.3-4)

bigz operators: Basic arithmetic operators for large integers

Description

Addition, substraction, multiplication, division, remainder of division, multiplicative inverse, power and logarithm functions.

Usage

add.bigz(a, b)
sub.bigz(a, b = NULL)
mul.bigz(a, b)
div.bigz(a, b)
divq.bigz(a,b)
mod.bigz(a, b)
abs.bigz(a)
inv.bigz(a, b,...)
inv(a, ...)
pow.bigz(a, b,...)
pow(a, ...)
log.bigz(x, base=exp(1))
log2.bigz(a)
log10.bigz(a)

Arguments

x
bigz, integer or string from an integer
a
bigz, integer or string from an integer
b
bigz, integer or string from an integer
base
base of the logarithm; base e as default
...
Additional parameters

Value

  • A bigz class representing the result of the arithmetic operation.

Details

For details about the internal modulus state, see the manpage of "bigz".

div or "/" return a rational number; divq or "%/%" return the quotient of division.

Operators can be use directly when objects are of class bigz: a + b, log(a), etc.

References

Gnu MP Library see http://swox.com/gmp

Examples

Run this code
# 1+1=2
as.bigz(1) + 1

# if my_large_number_string is set to a number, it returns the least byte
mod.bigz(as.bigz(my_large_number_string),"0xff")

# power exponents can be up to MAX_INT in size, or unlimited if a 
# bigz's modulus is set.
pow.bigz(10,10000)

Run the code above in your browser using DataLab